﻿@{
    ViewBag.Title = "State Maintenance";
    LineFocus.Nikcron.Models.Lookup Countries = ViewBag.Countries;    
}

@model Nickron.Database.State

@using (Html.BeginForm("StateMaintenance", "Master", FormMethod.Post, new { onsubmit = "return ValidateForm();"}))
{
    <div class="col-md-12">

        <div class="box box-danger">
            <div class="box-body">

                <div class="form-group">
                    <label> Country:</label>
                    <div class="input-group">
                        <div class="input-group-addon">
                            <i></i>
                        </div>
                        <select id="Country" name="Country" class="selectpicker show-tick" title="Select Country">
                            @Html.Partial("Dropdown", Countries)
                        </select>                       
                    </div><!-- /.input group -->
                </div><!-- /.form group -->

                <div class="form-group">
                    <label> State:</label><span class="astrisk">*</span>
                    <div class="input-group">
                        <div class="input-group-addon">
                            <i class=""></i>
                        </div>
                        <input id="State" name="State" type="text" maxlength="50" class="form-control pull-right" />
                    </div><!-- /.input group -->
                </div><!-- /.form group -->
               
                <div class="box-footer">
                    <input type="hidden" name="Id" id="Id" value="@ViewBag.Id" />
                    <button type="submit" class="btn btn-primary" style=" width:80px;">Save</button>
                    <button type="reset" class="btn btn-primary" style=" width:80px;">Cancel</button>
                </div>
             
            </div><!-- /.box-body -->
        </div><!-- /.box -->
    </div><!-- /.col (left) -->
 
}

<script type="text/javascript">

    function ValidateForm() {
        RequiredDropdown("Country", -1, "Select a Country");
        RequiredTextbox("State", "Enter the State Name");       
        return AlertError();
    }
    $(document).ready(function () {

        $('.selectpicker').selectpicker();
      
        if ("@ViewBag.Id" != "") {
            $('#Country').selectpicker("val", "@Model.CountryId");              
            $('#Id').val("@Model.Id");
            $('#State').val("@Model.Name");          
        }
    });
</script>